package com.example.suze.libraryinformationmanagementsystem.Fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.suze.libraryinformationmanagementsystem.Activity.AddActivity;
import com.example.suze.libraryinformationmanagementsystem.Activity.DeleteActivity;
import com.example.suze.libraryinformationmanagementsystem.Activity.LentActivity;
import com.example.suze.libraryinformationmanagementsystem.Activity.MainActivity;
import com.example.suze.libraryinformationmanagementsystem.Activity.ResultActivity;
import com.example.suze.libraryinformationmanagementsystem.Activity.ReturnActivity;
import com.example.suze.libraryinformationmanagementsystem.R;

/**
 * Created by suze on 2017/6/10.
 */

public class AdministrationFragment extends Fragment implements View.OnClickListener{
    private TextView add,delete,out,in;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
        super.onCreateView(inflater, container, savedInstanceState);
        View chatView = inflater.inflate(R.layout.fragment_administration, container,false);
        return chatView;


    }


    @Override
    public void onActivityCreated(Bundle savedInstanceState){
        add = (TextView) getView().findViewById(R.id.new_book);
        delete = (TextView) getView().findViewById(R.id.delete_book);
        out = (TextView) getView().findViewById(R.id.tv_administration_out);
        in = (TextView) getView().findViewById(R.id.tv_administration_in);
        add.setOnClickListener(this);
        delete.setOnClickListener(this);
        out.setOnClickListener(this);
        in.setOnClickListener(this);
        super.onActivityCreated(savedInstanceState);
    }

    @Override
    public void onClick(View v) {
        MainActivity mainActivity = (MainActivity) getActivity();
        switch (v.getId()){
            case R.id.new_book:
                Intent intent = new Intent(mainActivity, AddActivity.class);
                startActivity(intent);
                break;
            case R.id.delete_book:
                Intent intent3 = new Intent(mainActivity, DeleteActivity.class);
                startActivity(intent3);
                break;
            case R.id.tv_administration_out:
                Intent intent2 = new Intent(mainActivity, LentActivity.class);
                startActivity(intent2);
                break;
            case R.id.tv_administration_in:
                Intent intent1 = new Intent(mainActivity, ReturnActivity.class);
                startActivity(intent1);
                break;
        }
    }
}
